package com.ruoyi.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.domain.Administration;
import com.ruoyi.mapper.AdministrationMapper;
import com.ruoyi.service.IAdministrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.AdsRecoverStationMapper;
import com.ruoyi.domain.AdsRecoverStation;
import com.ruoyi.service.IAdsRecoverStationService;

/**
 * 行政审批回收站Service业务层处理
 * 
 * @author ya
 * @date 2025-08-27
 */
@Service
public class AdsRecoverStationServiceImpl extends ServiceImpl<AdsRecoverStationMapper,AdsRecoverStation> implements IAdsRecoverStationService
{
    @Autowired
    private AdsRecoverStationMapper adsRecoverStationMapper;

    @Autowired
    private IAdministrationService administrationService;


    @Override
    public int recoverData(Long[] recoverIds) {
        int count = 0;
        for (Long id : recoverIds){
            AdsRecoverStation adsRecoverStation = this.getById(id);
            //System.out.println("回收站数据:"+adsRecoverStation.toString());
            //审批数据
            Administration administration = new Administration();

            if (adsRecoverStation != null){
                administration.setId((long) adsRecoverStation.getAdsId());
                if (adsRecoverStation.getItem()!=null)
                    administration.setItem(adsRecoverStation.getItem());
                if (adsRecoverStation.getNumber()!=null)
                    administration.setNumber(adsRecoverStation.getNumber());
                if (adsRecoverStation.getFilm()!=null)
                    administration.setFilm(adsRecoverStation.getFilm());
                if (adsRecoverStation.getDate()!=null)
                    administration.setDate(adsRecoverStation.getDate());
                if (adsRecoverStation.getState()!=null)
                    administration.setState(adsRecoverStation.getState());
                if (adsRecoverStation.getWriter()!=null)
                    administration.setWriter(adsRecoverStation.getWriter());
                if (adsRecoverStation.getPubdate()!=null)
                    administration.setPubdate(adsRecoverStation.getPubdate());
                if (adsRecoverStation.getOrigin()!=null)
                    administration.setOrigin(adsRecoverStation.getOrigin());
                if (adsRecoverStation.getClick()!=null)
                    administration.setClick(adsRecoverStation.getClick());
                if (adsRecoverStation.getFilePath()!=null)
                    administration.setFilePath(adsRecoverStation.getFilePath());
                if (adsRecoverStation.getAppval()!=null)
                    administration.setAppval(adsRecoverStation.getAppval());
                if (adsRecoverStation.getKind()!=null)
                    administration.setKind(adsRecoverStation.getKind());
                if (adsRecoverStation.getRemark()!=null)
                    administration.setRemark(adsRecoverStation.getRemark());
                if (adsRecoverStation.getCreateTime()!=null)
                    administration.setCreateTime(adsRecoverStation.getCreateTime());
                if (adsRecoverStation.getUpdateTime()!=null)
                    administration.setUpdateTime(adsRecoverStation.getUpdateTime());
                if (adsRecoverStation.getCreateBy()!=null)
                    administration.setCreateBy(adsRecoverStation.getCreateBy());
                if (adsRecoverStation.getUpdateBy()!=null)
                    administration.setUpdateBy(adsRecoverStation.getUpdateBy());
            }
            System.out.println(administration.toString());
            administrationService.save(administration);
            adsRecoverStationMapper.deleteById(adsRecoverStation);//删除回收站数据
            count++;
        }
        return count;
    }

    /**
     * 查询行政审批回收站
     * 
     * @param id 行政审批回收站主键
     * @return 行政审批回收站
     */
    @Override
    public AdsRecoverStation selectAdsRecoverStationById(String id)
    {
        return adsRecoverStationMapper.selectAdsRecoverStationById(id);
    }

    /**
     * 查询行政审批回收站列表
     * 
     * @param adsRecoverStation 行政审批回收站
     * @return 行政审批回收站
     */
    @Override
    public List<AdsRecoverStation> selectAdsRecoverStationList(AdsRecoverStation adsRecoverStation)
    {
        return adsRecoverStationMapper.selectAdsRecoverStationList(adsRecoverStation);
    }

    /**
     * 新增行政审批回收站
     * 
     * @param adsRecoverStation 行政审批回收站
     * @return 结果
     */
    @Override
    public int insertAdsRecoverStation(AdsRecoverStation adsRecoverStation)
    {
        adsRecoverStation.setCreateTime(DateUtils.getNowDate());
        return adsRecoverStationMapper.insertAdsRecoverStation(adsRecoverStation);
    }

    /**
     * 修改行政审批回收站
     * 
     * @param adsRecoverStation 行政审批回收站
     * @return 结果
     */
    @Override
    public int updateAdsRecoverStation(AdsRecoverStation adsRecoverStation)
    {
        adsRecoverStation.setUpdateTime(DateUtils.getNowDate());
        return adsRecoverStationMapper.updateAdsRecoverStation(adsRecoverStation);
    }

    /**
     * 批量删除行政审批回收站
     * 
     * @param ids 需要删除的行政审批回收站主键
     * @return 结果
     */
    @Override
    public int deleteAdsRecoverStationByIds(String[] ids)
    {
        return adsRecoverStationMapper.deleteAdsRecoverStationByIds(ids);
    }

    /**
     * 删除行政审批回收站信息
     * 
     * @param id 行政审批回收站主键
     * @return 结果
     */
    @Override
    public int deleteAdsRecoverStationById(String id)
    {
        return adsRecoverStationMapper.deleteAdsRecoverStationById(id);
    }
}
